<?php 
my_component_load('testing' , false);
my_component_load('paging' , false);  
my_component_load('pr_upload_gaji' );
$task = isset($_GET['task']) ? $_GET['task'] : ""; 
$jid = isset( $_GET['jid'] ) ? $_GET['jid']:  0;
$id = isset( $_GET['id'] ) ? $_GET['id']:  0;
$komponen_gaji_id = isset( $_GET['komponen_gaji_id'] ) ? $_GET['komponen_gaji_id']:  0; 
$page = isset( $_GET['t'] ) ? $_GET['t']:  0;
$sid = isset( $_GET['sid'] ) ? $_GET['sid']:  0;

$modul_name = "Penggajian _BN_ Setting _BN_ Upload Data";
 ini_set("max_execution_time","10000");
if($_SERVER['REQUEST_METHOD'] == "POST" ):
	switch($task){
		case "edit_page":
			$ver = validasi_input_tambah_data();
			
			if($ver){
				$errors = message_multi_error($ver);
				$content = $errors;
				$content .=  form_upload_view_create($komponen_gaji_id,$id); 
			}else{
				submit_upload_view_create($komponen_gaji_id,$id ); 
				$content = "Updated";
			}
			generate_my_web($content, "" , 'plain.php' );
			exit;
			break;
		case "detail_upload_page":
			$temp = my_get_data_by_id('temp_upload_gaji','id', 1);
			$query = "INSERT INTO pr_gaji_upload_view (SELECT '','{$komponen_gaji_id}',karyawan_id , '0' ,value FROM temp_upload_gaji)";
			my_query($query);
			$query2 = "TRUNCATE TABLE `temp_upload_gaji`";
			my_query($query2);
			if(file_exists($temp['dest']))unlink($temp['dest']);
			$content= "Update";
			generate_my_web($content, "" , 'plain.php' );
			exit;
			break;
		case "upload_page":
			$ver = upload_form_validate();
			 
			if($ver){
				$errors = message_multi_error($ver);
				$content = $errors;
				$content .= upload_form_page($page);
				generate_my_web($content, "" , 'plain.php?script=1' );
				exit;
			}else{
				$t=upload_form_page_submit();
				my_direct('index.php?com='.$_GET['com'].'&komponen_gaji_id='.$komponen_gaji_id.'&task=detail_upload_page&t='.$t);
			}
			break;
	}
else: 	
	
	
	if($task == 'detail_karyawan_list'){
		$pagename = $modul_name;
		load_facebox_script();
		$content =  list_karyawan_upload_gaji($komponen_gaji_id); 
	}elseif($task == "detail_upload_page"){ 
		$content =display_upload($page);
		generate_my_web($content, "" , 'plain.php' );
		exit; 
	}elseif($task == "edit"){
		$title= ($id > '0' ) ?  "Perubahan data upload gaji karyawan" : "Tambah dataupload gaji karyawan";
		facebox_page('index.php?com=pr_upload_gaji&task=edit_page&komponen_gaji_id='.$komponen_gaji_id.'&id='.$id , $title , 170	); 
	}elseif($task == "delete_confirn"){
		 delete_on_confirm_page($id); 
		 my_direct($_SERVER['HTTP_REFERER']);	
	}elseif($task == "upload"){
		$komponen_gajis = my_get_data_by_id('pr_komponen_gaji','komponen_gaji_id',$komponen_gaji_id); 	 
		$title= "Upload data ".$komponen_gajis['nama_komponen_gaji'] ;
		//$title= ($id > '0' ) ?  "Perubahan data upload gaji karyawan" : "Tambah dataupload gaji karyawan";
		facebox_page('index.php?com=pr_upload_gaji&task=upload_page&komponen_gaji_id='.$komponen_gaji_id.'&id='.$id , $title , 250	); 
	}elseif($task == "upload_page"){
		generate_my_web(upload_form_page(), "" , 'plain.php' );
		exit; 
	}elseif($task == "reuse"){
		 reuse($komponen_gaji_id);
		 my_direct($_SERVER['HTTP_REFERER']);
	}elseif($task == "resetgaji"){
		 reset_gaji($komponen_gaji_id);
		 my_direct($_SERVER['HTTP_REFERER']);	
	}elseif($task == "delete"){
		 delete_upload_view($id);
		 my_direct($_SERVER['HTTP_REFERER']);	
	}elseif($task =="edit_page"){
		$content = form_upload_view_create($komponen_gaji_id,$id); 
		generate_my_web($content, "" , 'plain.php' );
		exit;
	}else{
		$pagename = $modul_name;
		load_facebox_script();
		$content =  list_upload_gaji();
	
	}
endif;  
generate_my_web($content, $pagename );
?>